import pandas as pd
import numpy as np
from datetime import datetime
import matplotlib.pyplot as plt
import plotly.express as px
import plotly.graph_objects as go
licenced_cars = pd.read_csv('data/veh0203.csv')
licenced_cars.head()
| Year | Petrol | Diesel | Hybrid Electric | Plug-in Hybrid Electric | Battery Electric | Range-Extended Electric | Fuel Cell Electric | Gas | Other | Total | |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 1994 | 19620.898 | 1576.196 | 0.0 | 0.0 | 0.093 | 0.0 | 0.0 | 1.788 | 0.228 | 21199.203 |
| 1 | 1995 | 19499.763 | 1891.271 | 0.0 | 0.0 | 0.074 | 0.0 | 0.0 | 2.857 | 0.138 | 21394.103 |
| 2 | 1996 | 20051.602 | 2181.634 | 0.0 | 0.0 | 0.094 | 0.0 | 0.0 | 4.085 | 0.123 | 22237.538 |
| 3 | 1997 | 20384.711 | 2440.508 | 0.0 | 0.0 | 0.116 | 0.0 | 0.0 | 6.241 | 0.122 | 22831.698 |
| 4 | 1998 | 20590.535 | 2692.904 | 0.0 | 0.0 | 0.151 | 0.0 | 0.0 | 9.632 | 0.110 | 23293.332 |
#-------- plot
fig = px.line(licenced_cars, x=licenced_cars.Year, y=licenced_cars.drop(['Year', 'Total'], axis=1).columns,
title='Licenced cars by fuel type')
fig.update_xaxes(rangeslider_visible = True)
fig.show()
licenced_low_emission_total = pd.read_csv('data/veh0133_total.csv')
fig = px.line(licenced_low_emission_total, x=licenced_low_emission_total.Date,
y=licenced_low_emission_total.drop(['Date'], axis=1).columns,
title='Licenced ultra low emission cars by <b> fuel type </b>')
fig.update_xaxes(rangeslider_visible = True)
fig.show()
licenced_low_emission_bodytype = pd.read_csv('data/veh0133_by_bodytype.csv')
fig = px.line(licenced_low_emission_bodytype, x=licenced_low_emission_bodytype.Date,
y=licenced_low_emission_bodytype.drop(['Date'], axis=1).columns,
title='Licenced ultra low emission cars by <b> fuel type & car type </b>')
fig.update_xaxes(rangeslider_visible = True)
fig.show()
Note: Data after Q3 2019 reflects charging devices which were available at the end of each quarter. Data previous to this uses charging devices which were available at the end of October 2019 but were installed in previous quarters before this. Subsequently, these figures do not include any devices installed before Q3 2019 that were decomissioned or unavailable at the time.
ev_charging_total = pd.read_csv('data/electric-vehicle-charging-total.csv')
fig = px.line(ev_charging_total, x=ev_charging_total.Date,
y=ev_charging_total.drop(['Date'], axis=1).columns,
title='EV charging stations')
fig.update_xaxes(rangeslider_visible = True)
fig.show()
Provisional 1 average reported CO2 emissions figure of cars registered for the first time by data source, monthly, Great Britain from January 2003; also United Kingdom from July 2014
co2_cars= pd.read_csv('data/veh0156_cars.csv')
fig = px.line(co2_cars, x=co2_cars.Date,
y=co2_cars.drop(['Date'], axis=1).columns,
title='CO2 emissions of <b> cars </b> registered for the first time')
fig.update_xaxes(rangeslider_visible = True)
fig.show()
co2_cars= pd.read_csv('data/veh0156_lgv.csv')
fig = px.line(co2_cars, x=co2_cars.Date,
y=co2_cars.drop(['Date'], axis=1).columns,
title='CO2 emissions of <b> LGV\'s </b> registered for the first time')
fig.update_xaxes(rangeslider_visible = True)
fig.show()
Licensed cars at the end of the year by CO2 emission and VED band 1, Great Britain from 2007 2; also United Kingdom from 2014
co2_licenced_gb= pd.read_csv('data/veh0206_GB.csv')
fig = px.line(co2_licenced_gb, x=co2_licenced_gb.Year,
y=co2_licenced_gb.drop(['Year'], axis=1).columns,
title='CO2 emissions of licenced cars in <b>Great Britain</b>')
fig.update_xaxes(rangeslider_visible = True)
fig.show()
co2_licenced_uk= pd.read_csv('data/veh0206_UK.csv')
fig = px.line(co2_licenced_uk, x=co2_licenced_uk.Year,
y=co2_licenced_uk.drop(['Year'], axis=1).columns,
title='CO2 emissions of licenced cars in <b>United Kingdom</b>')
fig.update_xaxes(rangeslider_visible = True)
fig.show()